package library.base.mvp.presenter.event;

/**
 * Base Event for EventBus
 *
 * @author Created by qiang.hou on 2018/10/8.
 * @version 1.0
 */
public abstract class BaseEvent<T, T2, T3> {
    /**
     * default action tag for Initialization UI thread
     */
    public static final String ACTION_TAG_INIT_PROCESS = "init_process";
    /**
     * default action tag for Http Response error
     */
    public static final String ACTION_TAG_RESPONSE_ERROR = "network_response_error";
    /**
     * for different UI thread. default value: name of current class
     */
    public String eventTag;
    /**
     * same UI thread, different action
     */
    public String actionTag;
    /**
     * extra data
     */
    public T data;
    /**
     * extra data
     */
    public T2 data2;
    /**
     * extra data
     */
    public T3 data3;

    protected abstract String returnThreadTag();

    protected abstract String returnActionTag();

    public BaseEvent() {
        init();
    }

    public BaseEvent(T data) {
        this.data = data;
        init();
    }

    public BaseEvent(T data, T2 data2) {
        super();
        this.data = data;
        this.data2 = data2;
        init();
    }

    public BaseEvent(T data, T2 data2, T3 data3) {
        super();
        this.data = data;
        this.data2 = data2;
        this.data3 = data3;
        init();
    }

    private void init() {
        eventTag = returnThreadTag() == null ? getClass().getPackage() + getClass().getSimpleName() : returnThreadTag();
        actionTag = returnActionTag() == null ? ACTION_TAG_INIT_PROCESS : returnActionTag();
    }
}
